package com.deceen.common.security;

import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @author zhuchunfeng
 * @date 2019/7/18 17:11
 */

@Component
public class MD5PassWordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        return new Md5PasswordEncoder().encodePassword(charSequence.toString(), "");
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return new Md5PasswordEncoder().encodePassword(charSequence.toString(), "").equals(s);
    }
}
